/**
 *
 * @file output.h
 *
 * @brief Header file for output.c
 *
 * $Id : $
 * */

/*
 * This file is part of Tsar.
 *
 * Tsar is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tsar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tsar.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef OUTPUT_H
#define OUTPUT_H

/* -- S T A N D A R D  I N C L U D E S -- */
#include <stdio.h>

/* -- L O C A L  I N C L U D E S -- */
#include <options.h>


/* -- C O N S T A N T S -- */
/* messages priorities */
#define MESSAGE_INFO        4
#define MESSAGE_NOTICE      3
#define MESSAGE_WARNING     2
#define MESSAGE_CRITICAL    1
#define MESSAGE_ALERT       0
/** @def maximum level of verbosity we can deal with */
#define MAX_VERBOSITY_LEVEL 4


/* -- F U N C T I O N S  P R O T O T Y P E S -- */

/**
 * @brief Die :  perror and exit
 * @param str perror prefix
 * @retval No return
 */
void die( char * str );

/**
 * @brief perror wrapper adapted to our output model
 * @param str is a zero terminated string you want to print before error description
 * @see perror(3)
 */
void Perror( char * str );

/**
 * @brief write error message on stderr and output file (if any)
 * @param fmt format string and its parameters
 */
void print_error( char * fmt, ... );

/**
 * @brief Write error text in sterr and exit 
 * @param fmt char* format string, Following arguments are variables
 * @retval void No return
 */
void fatal( char * fmt, ... );

/**
 * @brief Write in stderr all debug text if debug is enabled  
 * @param fmt char* format string, Following arguments are variables
 * @retval void No return
 */
void debug( char *fmt, ...  );

/**
 * @brief  Print write messages if the priority is bigger than the verbosity level, in stdout and in the report file 
 * @param fmt char* format string, Following arguments are variables
 * @retval void No return
 */
void print( int priority, char *fmt, ... );

/**
 * @brief Init the output fonctions  
 * @param o opt_t* options structure
 * @retval void No return
 */
void init_output( opt_t * o );

/**
 * @brief stop output fonctions
 * @param void no param
 * @retval void No return
 */
void end_output( void );

/**
 * @brief Print ap in the stream  
 * @param stream FILE* File where ap is written 
 * @param format const char* format of ap 
 * @param ap va_list arguments list  
 * @retval void No return
 */
void print_and_flush( FILE *stream, const char *format, va_list ap );

#endif /* OUTPUT_H */

